# !/usr/bin/env python
# -*- coding:utf-8 -*-
'''
目标:
    显示财务数据表格

历史:
    2019-05-18 姚彧 创建
'''
__all__ = ['StockTableWidget']


from PyQt5.QtWidgets import QTableWidget, QTableWidgetItem

class StockTableWidget(QTableWidget):
    #def __init__(self, *args, **kwargs):
    #    super().__init__(self, *args, **kwargs)

    def updateDrawIndexes(self, indexes):
        self.filterIndexes = indexes

    def fill(self, stockdf):
        self.stockdf = stockdf
        columns = stockdf.columns
        indexes = stockdf.index
        self.setColumnCount(len(columns))
        self.setRowCount(len(indexes))

        self.setHorizontalHeaderLabels(list(columns))
        self.setVerticalHeaderLabels(list(indexes))

        for i,(_, row) in enumerate(stockdf.iterrows()):
            for j, cell in enumerate(row):
                self.setItem(i, j, QTableWidgetItem(str(cell)))

